#ifndef __KPF_SESSION_H__
#define __KPF_SESSION_H__

#include "KPF_Object.h"

#include "KPF_Socket.h"

#include "session.h"

#include "KPF_Guard.h"

#include "KPF_Socket.h"

#include "KPF_Addr.h"

#include "log.h"

class KPF_Event
{
public:
	KPF_Event( void );
	
	virtual ~KPF_Event( void );
	
	void setEventParam( CEventParam *pEventParam );
	
	void setEvent( C_SESSION_EVENT eEvent );
	
	C_SESSION_EVENT getEvent( void );
	
	CEventParam &getEventParam( void );
	
protected:

private:
	CEventParam m_EventParam;
	
	C_SESSION_EVENT m_eEvent;
};

class KPF_Session : virtual public KPF_Object
{
public:
	KPF_Session( void );
	
	virtual ~KPF_Session( void );
	
	virtual int32_t handle_input( const KPF_Socket *pSocket, const int8u_t *pData, const int32_t iDataLen ) = 0;

	virtual int32_t handle_output( const KPF_Socket *pSocket, const int8u_t *pData, const int32_t iDataLen ) = 0;
	
	virtual int32_t handle_event( const KPF_Event &eEvent ) = 0;
	
	void setSocket( CSocket *pSocket );
	
	KPF_Socket *getSocket( void );
	
	void netAddr( const CNetAddr *pNetAddr );
	
	KPF_Addr *netAddr( void );
	
	void setEvent( C_SESSION_EVENT eEvent, CEventParam *pEventParam );
	
	KPF_Event &getEvent( void );
	
	static int32_t onSessionBusiness( const struct CSession_t *pThis, 
					 		const CSocket *pSocket, 
				    		const int8u_t *pInData, 
				   	 	const int32_t iInDataLen, 
				   	 	const CNetAddr *pNetAddr, 
				   	 	void *pUserData );
				   	 	
	static int32_t onSessionEvent( const struct CSession_t *pThis, 
				 							const C_SESSION_EVENT eEvent, 
				 							const CEventParam *pEventParam, 
				 							const int32_t iEventParamSize, 
				 							void *pUserData );
protected:
	CSession *pm_Session;
private:
	KPF_Socket m_Socket;
	
	KPF_Event m_Event;	
	
	KPF_Addr m_Addr;
};

#endif/*  */
